<template>
  <rm-layout-top splitcolor="white" :splitwidth=5 :fixsize=35>
      <template v-slot:fix>
          <div style="height:35px;border:1px solid #CCC;padding:4px;width:100%">
              <el-button @click="btnConfirm">确 认</el-button>
              <el-button @click="btnCancel">取 消</el-button>
          </div>
      </template>
      <div style="height:100%;width:100%;">
          <vxe-table :data.sync="tableData" :loading="loading" :keyboard-config="keyConfig" :sort-config="{trigger: 'cell'}" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,showIcon:false}" @cell-dblclick="btnConfirm" @current-change="currentChangeEvent" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column ref="xTable" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
              <vxe-table-column field="lotno" title="商品批号" width="100" sortable></vxe-table-column>
              <vxe-table-column field="expirydate" title="有效期" width="90" header-align="center" align="center" sortable :formatter="['toDateString', 'yyyy-MM-dd']"> </vxe-table-column>
              <vxe-table-column field="lotbarcode" title="批号条码" width="110" sortable align="center"></vxe-table-column>
              <vxe-table-column field="qty" title="库存量" width="70" sortable align="center"></vxe-table-column>
              <vxe-table-column field="unit" title="单位" width="60" sortable align="center"></vxe-table-column>
              <vxe-table-column field="itemlotnoid" title="商品批次" width="60" sortable align="center"></vxe-table-column>
          </vxe-table>
      </div>
  </rm-layout-top>
</template>

<script type="text/javascript">
export default {
  props: { warehouseid: { type: [String, Number] }, itemlotnoid: { type: [String, Number] }, itemid: { type: [String, Number] } },
  name: "LIS124",
  data() {
      return {
          keyConfig: {
              isDel: true,
              isTab: true,
              isEdit: true,
              isArrow: true,
          },
          keyLocalConfig: {
              isArrow: true,
          },
          loading: false,
          tableData: [],
          selectRow: {},
      };
  },
  created() {
      this.InitPage();
  },
  methods: {
      InitPage() {
          this.$tool
              .request({
                  url: "ucent/ddl",
                  method: "post",
                  data: {
                      action: "invItemLotno",
                      warehouseid: this.warehouseid,
                      itemlotnoid: this.itemlotnoid,
                      itemid: this.itemid,
                  },
              })
              .then((res) => {
                  this.tableData = res.data;
                  if (res.data.length > 0) {
                      this.selectRow = res.data[0];
                      this.$refs.xTable.setCurrentRow(res.data[0]);
                  } else {
                      this.selectRow.lotno = "";
                      this.selectRow.itemlotnoid = "";
                      this.$refs.xTable.setCurrentRow(null);
                  }
                  this.loading = false;
              })
              .catch((err) => {
                  this.$alert(err, "出错");
                  this.loading = false;
              });
      },
      //确定
      btnConfirm() {
          this.$emit("change", this.selectRow.lotno, this.selectRow.itemlotnoid);
      },
      //取消
      btnCancel() {
          this.$emit("cancel", "");
      },
      //行选中
      currentChangeEvent({ row, column }) {
          this.selectRow = row;
      },
  },
};
</Script>

<style scoped>
</style>